<!-- SELECT2 EXAMPLE -->
<div class="box box-default">
	<div class="box-header with-border">
		<h3 class="box-title">添加文件</h3>
	</div>
	<!-- /.box-header -->
	<div class="box-body">
		<div class="row">
			<div class="col-md-11">
				<form class="form-horizontal" action="/manage/download/save" method="post" name="myform" id="myform">
					<div class="form-group">
						<label class="col-md-2 non-rpad control-label" for="title">文件名称：</label>
						<div class="col-md-6 non-lrpad" style="line-height: 24px">
							<input type="text" required name="title" id="title" class="form-control" value="<!--{$data['title']}-->" />
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 non-rpad control-label" for="pid">所属分类：</label>
						<div class="col-md-3 non-lrpad" style="line-height: 24px">
							<select name="pid" class="form-control" id='pid'>
								<!--{foreach($cat as $k=>$v)}-->
								<option value="<!--{$k}-->"<!--{ if($data['pid']==$k){echo "selected";}}-->>
									<!--{$v}--></option>
								<!--{/foreach}-->
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 non-rpad control-label" for="descript">文件简介：</label>
						<div class="col-md-6 non-lrpad" style="line-height: 24px">
							<input type="text" name="descript" id="descript" class="form-control" value="<!--{$data['descript']}-->" />
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 non-rpad control-label">上传文件：</label>
						<div class="col-xs-6 non-lrpad" style="line-height: 35px">
							<div class="col-xs-6">
								<button type="button" class="btn btn-success col-xs-10">+上传文件</button>
								<input type="file" name="upload" id="down_url" class="col-xs-10 btn-translatefile" onchange="ajaxFileUpload('down_url');"> 
								<input type="hidden" name="down_url" id="field_down_url" autocomplete="off" value="<!--{$data['down_url']}-->"> 
								<input type="hidden" name="file_size" id="file_size" value="<!--{$data['file_size']}-->"> 
							</div>
							<span id="file_upload"></span>
						</div>
					</div>	
					<div class="form-group">
						<!--{if($id)}-->
						<input type="hidden" name="id" value="<!--{$id}-->">
						<!--{/if}-->
						<input class="col-md-2 col-md-offset-5 btn btn-success" type="submit" value="提交" />
					</div>
				</form>
			</div>

		</div>
		<!-- /.row -->
	</div>
	<!-- /.box-body -->
</div>
	<style>
.btn-translatefile {
	position: absolute;
	height: 34px;
	opacity: 0;
	cursor: pointer;
}

img[src=''] {
	display: none;
}

img.uplaod {
	height: 120px;
	margin-left: 10px;
}

.version-list {
	display: none;
}
</style>
<!-- /.box -->
<script type="text/javascript" src="/static/js/ajaxfileupload.js"></script>
<script type="text/javascript">
		function ajaxFileUpload(id) {
			var url = '/manage/download/upload';
			$.ajaxFileUpload({
				url : url, //需要链接到服务器地址
				secureuri : false,
				fileElementId : id, //文件选择框的id属性
				dataType : 'json', //服务器返回的格式，可以是json
				success : function(data, status) {
					//alert(this.fileElementId);
					var that = this;
					if (data.status == '1') {
						$('#file_size').val(data.size);
						$('#field_down_url').val(data.data);
						$('#file_upload').html("<font color='red'>文件已上传</font>");
					} else {
						alert(data.msg);
					}
				},
				error : function(data, status, e) {
					alert(e);
				}
			});
		}
		</script>